import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'


import axios from "axios";
axios.defaults.baseURL = "https://m.maizuo.com";

// 引入 vant Toast 插件消息提示
import { Toast } from 'vant';
import 'vant/es/toast/style';
// 请求拦截
axios.interceptors.request.use(
  config => {
    config.headers = {
      "X-Client-Info": '{"a":"3000","ch":"1002","v":"5.0.4","e":"1598087896889693885431809","bc":"110100"}',
      "X-Host": "mall.film-ticket.film.list",
    };
    // 在发送请求之前做些什么
    return config;
  },
  error => {
    Toast("网络请求错误，请检查网络！")
    return Promise.reject(error);
  }
)
// 响应拦截
axios.interceptors.response.use(res => {
  if (res.data.msg === "ok") {
    Toast("成功返回数据！");
    return res.data;
  } else {
    Toast("数据错误反馈，请检查输入！")
  }
}, err => {
  console.log(err);
  Toast("网络请求错误，请检查网络！")
});

// 发送请求
(async () => {
  const res = await axios.get("gateway?cityId=110100&pageNum=1&pageSize=10&type=1&k=8591124");
  console.log(res);
})();



createApp(App).use(store).use(router).mount('#app')
